import type {
  GetCodeData,
  GetCodeParams,
  LoginCodeData,
  LoginCodeParams,
  LoginDataType,
  LoginParams,
  UserData,
} from '@/types/user'
import request from '@/utils/request'

// 1. 封装API函数
export const loginByPasswordAPI = (data: LoginParams) => {
  //第二个参数是泛型，指定返回值的类型
  return request.post<null, LoginDataType>('/login/password', data)
}

export const getCodeAPI = (params: GetCodeParams) => {
  return request.get<null, GetCodeData>('/code', { params })
}

export const loginByMobileApi = (data: LoginCodeParams) => {
  return request.post<null, LoginCodeData>('/login', data)
}

//个人信息
export const userInfoApi = () => {
  return request.get<null, UserData>('/patient/myUser')
}
